<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Mail
 *
 * @author YL-Z0016
 */
class Mail {
    private $_smarty = null;
    function __construct(){
        include __ROOT.'libs/smarty3/Smarty.class.php';
        $this->$_smarty = new Smarty;
        $this->$_smarty->setTemplateDir(APP_TEMPLATES.'/mail');
        $this->$_smarty->setCompileDir(__ROOT.'smarty/cache');
        $this->$_smarty->setPluginsDir(__ROOT.'smarty/plugins');
    } 
    public function add($k,$v){
        $this->$_smarty->assign($k,$v);
    }
    /**
     *发送邮件
     * @param type $mail
     * @param type $subject
     * @param type $template
     * @return type 
     */
    public function send($mail,$subject,$template){
        $body = $this->$_smarty->fetch($template.'.htm');
        $headers = 'From: noreplay@taoxueba.com' . "\r\n" .
                'MIME-Version: 1.0' . "\r\n".
                'Content-type: text/html; charset=utf-8' . "\r\n".
                'Reply-To: noreplay@taoxueba.com' . "\r\n" .
                'X-Mailer: PHP/' . phpversion();
        return mail($mail, $subject, $body, $headers);
    }
}

?>
